<!-- daterange picker -->
<link rel="stylesheet" href="__PUBLIC__/AdminLTE/plugins/daterangepicker/daterangepicker.css">
<div class="content-wrapper">
    <section class="content-header">
        <h1>订单列表</h1>
        <ol class="breadcrumb">
            <li><a href="/"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li class="active">订单管理</li>
            <li class="active">订单列表</li>
        </ol>
    </section>
    <section class="content">
        <div class="box">
            <div class="box-header with-border">
                <form class="form-inline" action="/order/salesmanOrderList" method="get">
                    <input type="hidden" class="form-control" id="flag" name="flag" value="{$flag}">
                    <div class="form-group">
                        <label for="order_code">订单号 </label>
                        <input type="text" class="form-control" id="order_code" name="order_code" placeholder="订单号" value="{$order_code}">
                    </div>
                    <div class="form-group">
                        <label for="name">公司名称 </label>
                        <input type="text" class="form-control" id="company_name" name="company_name" placeholder="公司名称" value="{$company_name}">
                    </div>
                    <div class="form-group">
                        <label class="label-control" for="status">状态 </label>
                        <select id="status" name="status" class="form-control">
                            <option value="0">请选择</option>
                            <foreach name="orderStatusList" item="status_val" key="key_val">
                                <option value="{$key_val}" <if condition="$key_val eq $status ">selected</if>>{$status_val}</option>
                            </foreach>
                        </select>
                    </div>
                    <div class="form-group">
                        <label>日期</label>
                        <div class="input-group">
                            <div class="input-group-addon">
                                <i class="fa fa-calendar"></i>
                            </div>
                            <input type="text" class="form-control pull-right" name="search_time" id="reservation" value="{$search_time}">
                        </div>
                        <!-- /.input group -->
                    </div>
                    <button type="submit" class="btn btn-info" id="save-btn">查询</button>
                </form>
            </div>
            <div class="box-body table-responsive">
                <table class="table table-bordered">
                    <tbody>
                    <tr>
                        <th style="width: 80px">ID</th>
                        <th>订单ID</th>
                        <th>公司名称</th>
                        <th>推广产品</th>
                        <th>联系人</th>
                        <th>销售金额</th>
                        <th>成本</th>
                        <th>毛利</th>
                        <th>其他费用</th>
                        <th>状态</th>
                        <th>下单时间</th>
                        <th style="width: 120px">操作</th>
                    </tr>
                    <if condition="count($orderList) eq 0"><tr><td class="text-center" colspan="12">暂无数据...</td></tr></if>
                    <foreach name="orderList" item="order">
                        <tr>
                            <td>{$order.order_id}</td>
                            <td>{$order.order_code}</td>
                            <td>{$order.company_name}</td>
                            <td>{$order.product_name}</td>
                            <td>{$order.name}</td>
                            <td>{$order.amount}</td>
                            <td>{$order.base_price}</td>
                            <td>{$order.profit_price}</td>
                            <td>{$order.other_price}</td>
                            <td><p>{$order.status_desc}</p>
                                <if condition="$order.status eq 35 ">
                                    <if condition="$order.dp_manager_review eq 1 ">
                                        <span class="label label-success">已通过</span>
                                        <else />
                                        <span class="label label-danger">已拒绝</span>
                                    </if>
                                    <elseif condition="$order.status eq 40 " />
                                    <if condition="$order.director_review eq 1 ">
                                        <span class="label label-success">已通过</span>
                                        <else />
                                        <span class="label label-danger">已拒绝</span>
                                    </if>
                                    <elseif condition="$order.status eq 45 " />
                                    <if condition="$order.g_manager_review eq 1 ">
                                        <span class="label label-success">已通过</span>
                                        <else />
                                        <span class="label label-danger">已拒绝</span>
                                    </if>
                                </if>
                            </td>
                            <td>{$order.create_time}</td>
                            <td style="width: 120px">
                                <button class="btn btn-primary btn-xs" type="button" onclick="window.location.href='/order/salesmanOrderDetail?order_id={$order.order_id}'">详情</button>&nbsp;
                                <php>if($order['status']!=-1){</php>
                                <button class="btn btn-success btn-xs" type="button" onclick="window.location.href='/order/applyOrderBill?order_id={$order.order_id}'">申请发票</button>&nbsp;
                                <php>}</php>
                            </td>
                        </tr>
                    </foreach>
                    </tbody>
                </table>
            </div>
            <div class="box-footer clearfix">{$page_html}</div>
        </div>
    </section>
</div>
<!-- date-range-picker -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.11.2/moment.min.js"></script>
<script src="__PUBLIC__/AdminLTE/plugins/daterangepicker/daterangepicker.js"></script>
<script type="application/javascript">
    $(function () {
        //Date range picker
        $('#reservation').daterangepicker({
            autoUpdateInput: false,
            applyClass : 'btn-sm btn-success',
            cancelClass : 'btn-sm btn-default',
            locale: {
                applyLabel: '确认',
                cancelLabel: '取消',
                fromLabel : '起始时间',
                toLabel : '结束时间',
                customRangeLabel : '自定义',
                weekLabel: 'W',
                daysOfWeek:['日','一','二','三','四','五','六'],
                monthNames:['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
                firstDay : 1
            },
            startDate: new Date(),
            endDate: new Date(),
            ranges: {
                '今天': [moment(), moment()],
                '昨天': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
                '最近7天': [moment().subtract(6, 'days'), moment()],
                '最近30天': [moment().subtract(29, 'days'), moment()],
                '本月': [moment().startOf('month'), moment().endOf('month')],
                '上个月': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
            }
        });
        $('#reservation').on('apply.daterangepicker', function(ev, picker) {
            $(this).val(picker.startDate.format('MM/DD/YYYY') + ' - ' + picker.endDate.format('MM/DD/YYYY'));
        });
        $('#reservation').on('cancel.daterangepicker', function(ev, picker) {
            $(this).val('');
        });
    });
</script>